function displayResource(id){    
    $("#table-resource tr").each(function(rowIndex) {            
        $(this).find("td").each(function(cellIndex){             
            var data = $(this).find('a').attr('onclick');            
            if(data == 'displayResource('+id+')'){
                $(this).find('a').toggleClass('btn-green');
                $(this).find('a').toggleClass('btn-red');
                $(this).find('i').toggleClass('fontello-icon-ok-2');
                $(this).find('i').toggleClass('fontello-icon-cancel-2');
            }
        });
    });
    $.ajax({
        type: "post",
        url : "admin/resource/display/",
        data: {
            resourceId : id,
            act : 'display'
        },
        success: function(data){
        },
        error: function(data){
        }
    });
}
$('#supportMenu').change(function(){         
    $('#menuName').val($('#supportMenu option:selected').text());
    $('#menuModel').val($('#supportMenu').val());   
});
$(document).ready(function(){
    //$('#menuName').val($('#supportMenu option:selected').text());
    //$('#menuModel').val($('#supportMenu').val());
});
$(':text#moduleName').keyup(function(){
    supportMenu();    
});
$(':text#controllerName').keyup(function(){
    supportMenu();    
});
$(':text#actionName').keyup(function(){
    supportMenu();    
});
function supportMenu(){
    var module =  $(':text#moduleName').val().toLowerCase().trim().replace(/[$^*(\\)+|?\[]/g,'');
    var controller = $(':text#controllerName').val().toLowerCase().trim().replace(/[$^*(\\)+|?\[]/g,'');
    var action = $(':text#actionName').val().toLowerCase().trim().replace(/[$^*(\\)+|?\[]/g,'');
    var unicodeNew = new Array();
    unicodeNew[''] = new Array('~','`','!','@','#','%','&','=',']','{','}',':',';','"',"'",'<','>','/',' ');
    for(var seoChar in unicodeNew){
        var uniArray = unicodeNew[seoChar];
        for(var i=0;i<uniArray.length;i++){
            var re = new RegExp(uniArray[i],'g');
            module = module.replace(re,seoChar);
        }
    }
    for(var seoChar in unicodeNew){
        var uniArray = unicodeNew[seoChar];
        for(var i=0;i<uniArray.length;i++){
            var re = new RegExp(uniArray[i],'g');
            controller = controller.replace(re,seoChar);
        }
    }
    for(var seoChar in unicodeNew){
        var uniArray = unicodeNew[seoChar];
        for(var i=0;i<uniArray.length;i++){
            var re = new RegExp(uniArray[i],'g');
            action = action.replace(re,seoChar);
        }
    }
    $(':text#menu').val(module+'/'+controller+'/'+action);
}
function fResourceTableDisplay(data,module){
    $(event.target).addClass('btn-green');
    $(event.target).parent().find('a').each(function(){        
        if($(this).attr('data')!=data){            
            $(this).removeClass('btn-green');
        }                             
    });    
    if(module=='admin'){        
        $('#tabResourceAdmin').find('table').each(function(){
            if($(this).attr('data') == data)
                $(this).css('display','table');
            else
                $(this).css('display','none');
        });                    
    }else{
        $('#tabResourceDefault').find('table').each(function(){
            if($(this).attr('data') == data)
                $(this).css('display','table');
            else
                $(this).css('display','none');
        });
    }
}
$('td[act="editable"] a[act="edit"]').click(function(){    
    var data = $(this).parent().attr('data');
    $('td[act="editable"][data="'+data+'"]').css('display','none');
    $('td[act="edit-detail"][data="'+data+'"]').css('display','table-cell');
    var editdata = $('td[act="editable"][data="'+data+'"]').text().trim();    
    $('td[act="edit-detail"][data="'+data+'"] input[act="input"]').val(editdata);    
});
$('td[act="edit-detail"] a[act="cancel"]').click(function(){
    var code = $(this).parent().attr('data'); 
    var editdata = $('td[act="edit-detail"][data="'+code+'"] input[act="input"]').val().trim();
    $('td[act="editable"][data="'+code+'"]').css('display','table-cell');
    $('td[act="edit-detail"][data="'+code+'"]').css('display','none');        
});
$('td[act="edit-detail"] a[act="save"]').click(function(){
    var code = $(this).parent().attr('data'); 
    var editdata = $('td[act="edit-detail"][data="'+code+'"] input[act="input"]').val().trim();
    $('td[act="editable"][data="'+code+'"]').css('display','table-cell');
    $('td[act="edit-detail"][data="'+code+'"]').css('display','none');    
    $.ajax({
        type: "post",
        url : "admin/resource/ord/",
        data: {
            resourceId : code,
            act : 'ord',
            ord : editdata
        },
        success: function(){
        },
        error: function(){
        }
    });    
    $('td[act="editable"][data="'+code+'"] label').text(editdata);    
});
$(':text#menuName').keyup(function(e){
        
});
$(':text#menuModel').keyup(function(e){
        
});